home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Gamer (Italian) 30
/
PC Gamer IT CD 30 1-2.iso
/
MOTS
/
GAMEDATA
/
RESOURCE
/
JKMRES.GOO
/
cog_weap_manseq_m.cog
< prev
next >
Wrap
Text File
|
1998-02-25
|
14KB
|
593 lines
# Jedi Knight Missions Cog Script
#
# WEAP_MANSEQ_M.COG
#
# WEAPON 18 Script - Manual Sequencer Charge
#
# Heartier than the Thermals and the DF IM Mines these are used by placing them on
# the ground or on walls. These have both delayed and proximity options.
#
# - Not affected by MagSealed sectors/surfaces.
#
# [YB & CYW] + [RF]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
# ========================================================================================
symbols
model povModel=seqb.3do local
model povModel_m=seqb_m.3do local
model fistMesh=fistg.3do local
model weaponMesh=seqg.3do local
# Animations that deal with bringing stuff up or down
# Note that impossible animations are left blank.
keyframe ChangeAnimEE local
keyframe ChangeAnimET=seqBmntl.key local
keyframe ChangeAnimEC=seqBmntr.key local
keyframe ChangeAnimEB=seqBmnt.key local
keyframe ChangeAnimTE=seqBdisl.key local
keyframe ChangeAnimTT local
keyframe ChangeAnimTC local
keyframe ChangeAnimTB=seqBmntTB.key local
keyframe ChangeAnimCE=seqBdisr.key local
keyframe ChangeAnimCT local
keyframe ChangeAnimCC local
keyframe ChangeAnimCB=seqBmntCB.key local
keyframe ChangeAnimBE=seqBdis.key local
keyframe ChangeAnimBT=seqBdisBT.key local
keyframe ChangeAnimBC=seqBdisBC.key local
keyframe ChangeAnimBB local
keyframe DismountAnim local
keyframe holsterAnim=kyhlstr.key local
int iSeqModel=1 local
# Trigger firing animations
keyframe povTriggerAnimT=seqBpstL.key local
keyframe povTriggerAnimB=seqBpst2.key local
# Charge laying animations
keyframe povFireAnimC=seqBpstR.key local
keyframe povFireAnimB=seqBpst1.key local
int IsFiring=0 local
int IsSelected=0 local
int IsActivated=0 local
flex fi local
flex mountWait local
flex fireWait=0.8 local
flex holsterWait local
# Amount of time to wait for "hitting trigger" animation to complete
# before activating the "bring down trigger hand" animation.
flex animWait local
template projectile_tpl=+seqchrg local
template projectile_tpl2=+seqchrg2 local
template projectile_tpl3=+seqchrg3 local
template projectile_tpl4=+seqchrg4 local
template projectileB=+dudseqchrg local
int projectileCount=0 local
# The next 10 items actually function
# as an array of lain projectiles.
int projectile local
int projectile2 local
int projectile3 local
int projectile4 local
int projectile5 local
int projectile6 local
int projectile7 local
int projectile8 local
int projectile9 local
int projectile10 local
int iCounter local
material flashing=seq0mtp3.mat local
int cel local
int mode local
thing player local
int trackID=-1 local
int holsterTrack local
int selectMode=1 local
message startup
message activated
message deactivated
message selected
message deselected
#message newplayer
message autoselect
#message fire
message timer
message killed
end
# ========================================================================================
code
startup:
// Setup delays and variables.
mountWait = GetKeyLen(mountAnim);
// Start the material flashing.
MaterialAnim( flashing, 4, 1 );
Return;
# ........................................................................................
ofire:
if (IsFiring)
return;
if (!IsSelected)
return;
// Check that the player is still alive.
if(GetThingHealth(player) <= 0)
Return;
SendMessageEx(GetThingClassCog(GetLocalPlayerThing()), user1, 3, 0, 0, 0);
if (GetInv(player, 93) > 0.0)
{
projectile = FireProjectile(player, projectileB, -1, 16, '0 0.05 0.00', '0 0 0', 1.0, 0, 0.0, 0.0);
if (GetSenderID() == 2)
{
StopKey(player, holsterTrack, 0.0);
}
else
jkPlayPOVKey(player, povfireAnim, 1, 0x38);
ChangeInv(player, GetWeaponBin(8), -1.0);
// If out of ammo try to autoswitch to another weapon
// if autoswitch is enabled else just switch to fists.
if(GetInv(player, GetWeaponBin(8)) < 1)
{
SetInv(player, GetWeaponBin(18), 0.0);
if(GetAutoSwitch() & 1)
{
SelectWeapon(player, GetWeaponBin(AutoSelectWeapon(player, 1)));
}
else
{
SelectWeapon(player, 1);
}
}
return;
}
animWait = 0.0;
// User hit the detonator
if (mode == 1)
{
if (projectileCount > 0)
call detonateall;
else
jkPrintUNIString(player, 370); // "Nothing to detonate!"
return;
}
if(GetInv(player, GetWeaponBin(8)) < 1)
{
jkPrintUNIString(player, 371); // "You have no charges to lay!"
return;
}
if (mode == 0 && projectileCount >= 10)
{
jkPrintUNIString(player, 372); // "You may only place 10 charges!"
return;
}
isFiring = 1;
if (GetSenderID() == 2)
{
StopKey(player, holsterTrack, 0.0);
}
else
{
if (IsSelected)
{
if (projectileCount)
{
animWait = GetKeyLen(povFireAnimB);
call stoptrack;
trackID = jkPlayPOVKey(player, povFireAnimB, 1, 20);
}
else
{
animWait = GetKeyLen(povFireAnimC);
call stoptrack;
trackID = jkPlayPOVKey(player, povFireAnimC, 1, 20);
}
}
}
projectile[projectileCount] = FireProjectile(player, projectile_tpl[mode+2], -1, 16, '0 0.05 0.00', '0 0 0', 1.0, 0, 0.0, 0.0);
// If we successfully placed a charge, make an appointment to try again.
// isFiring will be cleared by this timer callback.
SetTimerEx(fireWait, 3, 0.0, 0.0);
// Change both bins associated with this weapon.
ChangeInv(player, GetWeaponBin(8), -1.0);
if (GetWeaponBin(8) <= 0.0)
{
if (iSeqModel == 1)
{
jkSetWeaponMesh(player, fistMesh);
iSeqModel = 0;
}
}
animWait = 0.0;
// If they layed a charge, bring up the trigger.
if ((!projectileCount) && (IsSelected))
{
animWait = GetKeyLen(ChangeAnimEB);
call stoptrack;
trackID = jkPlayPOVKey(player, ChangeAnimEB, 2, 20);
}
else
{
animWait = GetKeyLen(ChangeAnimTB);
call stoptrack;
trackID = jkPlayPOVKey(player, ChangeAnimTB, 2, 20);
}
projectileCount = projectileCount + 1;
SetInv(player, GetWeaponBin(18), 2.0);
// If they are out of ammo, bring down the charge.
if((GetInv(player, GetWeaponBin(8)) < 1) && (IsSelected))
{
call stoptrack;
trackID = jkPlayPOVKey(player, ChangeAnimBT, 2, 20);
}
Return;
# ........................................................................................
activated:
player = GetSourceRef();
mode = GetSenderRef();
if(mode > 1)
{
Return;
}
IsActivated = 1;
// Don't reenter!
// if (IsFiring || !IsSelected)
// return;
call ofire;
Return;
# ........................................................................................
deactivated:
IsActivated = 0;
player = GetSourceRef();
mode = GetSenderRef();
// jkSetWaggle(player, '10.0 7.0 0.0', 350);
// DeactivateWeapon( player, mode );
Return;
# ........................................................................................
selected:
player = GetSourceRef();
if ((!projectileCount) && (!GetInv(player, GetWeaponBin(8))))
return;
jkPrintUNIString(player, 373); // "Manual Mode"
PlayMode(player, 40);
if (GetWeaponBin(8) > 0.0)
{
jkSetWeaponMesh(player, weaponMesh);
iSeqModel = 1;
}
else
{
jkSetWeaponMesh(player, fistMesh);
iSeqModel = 0;
}
SetArmedMode(player, 0);
if (GetInv(player, 67) == 0.0)
jkSetPOVModel(player, povModel); // Kyle hand
else
jkSetPOVModel(player, povModel_m); // Mara Hand
if (projectileCount)
{
// If they have ammo, bring up the charge and the trigger.
if (GetInv(player, GetWeaponBin(8)))
{
call stoptrack;
trackID = jkPlayPOVKey(player, ChangeAnimEB, 0, 20);
DismountAnim = ChangeAnimBE;
}
else
{
// Otherwise, just bring up the trigger.
call stoptrack;
trackID = jkPlayPOVKey(player, ChangeAnimET, 0, 20);
DismountAnim = ChangeAnimTE;
}
}
else
{
// If there are no charges on the ground, don't bring up the trigger.
call stoptrack;
trackID = jkPlayPOVKey(player, ChangeAnimEC, 0, 20);
DismountAnim = ChangeAnimCE;
}
jkSetWaggle(player, '10.0 7.0 0.0', 350);
SetMountWait(player, GetKeyLen(mountAnim));
jkClearFlags(player, 0x5);
SetCurWeapon(player, GetWeaponBin(18));
IsSelected = 1;
Return;
# ........................................................................................
deselected:
// If we are switching away from the trigger, detonate the charge.
// if (projectileCount != 0)
// call detonateall;
IsSelected = 0;
player = GetSourceRef();
if (DismountAnim)
{
call stoptrack;
trackID = jkPlayPOVKey(player, DismountAnim, 0, 18);
}
holsterWait = GetKeyLen(holsterAnim);
SetMountWait(player, holsterWait);
holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
SetTimerEx(holsterWait, 2, 0.0, 0.0);
if (trackID != -1)
{
jkStopPOVKey(player, trackID, 0);
trackID = -1;
}
jkSetWaggle(player, '0.0 0.0 0.0', 0);
Return;
# ........................................................................................
//newplayer:
// player = GetSourceRef();
//
// // Make sure that if the player is respawning, the old mount isn't playing anymore.
// if (trackID != -1)
// jkStopPOVKey(player, trackID, 0);
//
// Return;
# ........................................................................................
autoselect:
selectMode = GetSenderRef();
player = GetSourceRef();
// Check to see if it's time to switch POV Models.
if (GetCurWeapon(player) == 18)
{
if(GetInv(player, GetWeaponBin(8)) < 1)
{
if (iSeqModel == 0)
{
jkSetWeaponMesh(player, weaponMesh);
iSeqModel = 1;
}
}
else
{
if (iSeqModel == 1)
{
jkSetWeaponMesh(player, fistMesh);
iSeqModel = 0;
}
}
}
// If the player has ammo (in hand or on the floor)
if((GetInv(player, GetWeaponBin(8)) > 1) || (projectileCount > 0))
{
// query for ammo
if(selectMode == -1)
{
ReturnEx(300.0);
Return;
}
if((selectMode == 0) && !(GetAutoPickup() & 2))
{
ReturnEx(300.0);
Return;
}
if((selectMode == 1) && !(GetAutoSwitch() & 2))
{
ReturnEx(300.0);
Return;
}
if((selectMode == 2) && !(GetAutoPickup() & 2))
{
ReturnEx(300.0);
Return;
}
ReturnEx(-2.0);
Return;
}
else
{
ReturnEx(-1.0);
}
Return;
# ........................................................................................
timer:
if (GetSenderID() == 2)
{
StopKey(player, holsterTrack, 0.0);
}
else if (GetSenderID() == 3)
{
// Allow further firing.
isFiring = 0;
if ((mode == 0) && IsActivated)
call ofire;
}
else if (GetSenderID() == 4)
{
if (GetCurWeapon(player) == 18)
if(GetThingHealth(player) > 0)
{
if(GetAutoSwitch() & 1)
{
SelectWeapon(player, AutoSelectWeapon(player, 1));
}
else
{
SelectWeapon(player, GetWeaponBin(1));
}
}
}
Return;
# ........................................................................................
detonateall:
animWait = 0.0;
if (IsSelected)
{
// If we don't have any more charges, play the trigger only animation.
if(GetInv(player, GetWeaponBin(8)) < 1)
{
animWait = GetKeyLen(povTriggerAnimT);
call stoptrack;
trackID = jkPlayPOVKey(player, povTriggerAnimT, 2, 20);
DismountAnim = 0;
}
else
{
animWait = GetKeyLen(povTriggerAnimB);
call stoptrack;
trackID = jkPlayPOVKey(player, povTriggerAnimB, 2, 20);
DismountAnim = ChangeAnimCE;
}
}
for (iCounter = 0; iCounter < projectileCount; iCounter = iCounter + 1)
{
SetLifeLeft(projectile[iCounter], 0.1+(iCounter*0.1));
}
projectileCount = 0;
if (IsSelected)
{
// If out of ammo try to autoswitch to another weapon
// if autoswitch is enabled else just switch to fists.
if(GetInv(player, GetWeaponBin(8)) < 1)
{
jkSetWeaponMesh(player, fistMesh);
SetInv(player, GetWeaponBin(18), 0.0);
SetTimerEx(1.0, 4, 0, 0);
}
else
{
SetInv(player, GetWeaponBin(18), 1.0);
// Bring the trigger down, but leave the charge up.
if (animWait > 0.0)
sleep(animWait);
call stoptrack;
trackID = jkPlayPOVKey(player, ChangeAnimBC, 2, 20);
}
}
Return;
# ........................................................................................
killed:
// Deactivate the weapon.
if (projectileCount > 0)
call detonateall;
IsActivated = 0;
IsFiring = 0;
return;
# ........................................................................................
stoptrack:
if (trackID != -1)
{
jkStopPOVKey(player, trackID, 0);
trackID = -1;
}
return;
end